<div class="access-notification" ng-if="vm.isNotHavePermissions" i-translate="ACCESS_DENIED"></div>
<div class="experiments" ng-if="!vm.isNotHavePermissions"
     detect-rendered="vm.deferLoading.resolve()">
    <autorecovery kind="{{vm.stateData.tab.kind}}"
                  name="{{vm.experiment.name}}"
                  on-restore="vm.onRestore(recoveryData)">
    </autorecovery>
    <div class="tab-content-pad">
        <div class="row m-b20">
            <div class="col-sm-6 col-xs-9">
                <div class="row-inline">
                    <span class="txt-larger"><span i-translate="EXPERIMENT_MEMBERS"></span>:</span>
                    <button type="submit" ui-sref="entities.experiment-detail.permissions()"
                            class="btn btn-default btn-small" ng-disabled="!vm.isComponentsEditAllowed">
                        <span class="icon icon-edit"></span>
                        <span class="m-l5" i-translate="EDIT"></span>
                    </button>
                    <button type="button" class="btn btn-default btn-small"
                            ui-sref="entities.experiment-detail.permissions-view()">
                        <span class="icon icon-eye"></span>
                        <span class="m-l5" i-translate="VIEW_MEMBERS"></span>
                    </button>
                </div>
            </div>
            <div class="col-sm-6 col-xs-3">
                <div class="row-inline">
                    <span class="txt-larger"><span i-translate="STATUS"></span>:</span>
                    <span class="uui-label" ng-bind="vm.experiment.status"></span>
                </div>
            </div>
        </div>
    </div>

    <form name="experimentForm" id="experimentForm" role="form" novalidate ng-submit="vm.save()">
        <indigo-components template="vm.experiment.template.templateContent"
                           is-readonly="!vm.isComponentsEditAllowed"
                           model="vm.experiment.components"
                           experiment="vm.experiment"
                           save-experiment-fn="vm.save()"
                           on-changed="vm.onChangedComponent(componentId)">
        </indigo-components>
    </form>
    <div class="btn-bottom-block tab-content-pad">
        <!--TODO: Task EPMLSOPELN-532: Functionality is temporarily removed-->
        <!--<div class="pull-left">-->
            <!--<button type="button" class="btn btn-default" ng-disabled="!vm.canUndo()" ng-click="vm.undoAction()">-->
                <!--<span class="icon icon-undo"></span><span class="m-l5">Undo Action</span>-->
            <!--</button>-->
            <!--<button type="button" class="btn btn-default" ng-disabled="!vm.canRedo()" ng-click="vm.redoAction()">-->
                <!--<span class="fa fa-redo"></span><span class="m-l5">Redo Action</span>-->
            <!--</button>-->
        <!--</div>-->
        <div class="btn-group dropup" uib-dropdown is-open="isopen">

            <button id="single-button" type="button" class="btn btn-info" uib-dropdown-toggle ng-disabled="disabled">
                <span class="m-r10" i-translate="ACTIONS"></span><span class="icon icon-arrow_down"></span>
            </button>
            <ul uib-dropdown-menu role="menu" aria-labelledby="single-button">
                <li role="menuitem"><a><span i-translate="STATUS"></span>: </span>
                    <strong ng-bind="vm.experiment.status"></strong></a></li>
                <li class="divider"></li>
                <li role="menuitem" ng-if="vm.isComponentsEditAllowed"
                    ng-click="vm.completeExperiment()"><a i-translate="COMPLETE_EXPERIMENT"></a></li>
                <li role="menuitem" ng-if="vm.isComponentsEditAllowed"
                    ng-click="vm.completeExperimentAndSign()"><a i-translate="COMPLETE_SIGN"> </a></li>
                <li role="menuitem" ng-if="vm.isEditAllowed && vm.isStatusSubmitFail"
                    ng-click="vm.reopenExperiment()"><a i-translate="REOPEN_EXPERIMENT_FOR_EDIT"></a></li>
                <li role="menuitem" ng-click="vm.repeatExperiment()"><a i-translate="REPEAT_EXPERIMENT"></a></li>
                <li role="menuitem"><a ng-click="vm.printExperiment()" i-translate="PRINT_EXPERIMENT"></a></li>
                <li role="menuitem"
                    ng-if="vm.experiment.lastVersion && !vm.isStatusOpen"
                    ng-click="vm.versionExperiment()"><a i-translate="VERSION_EXPERIMENT"></a></li>
                <li role="menuitem" ng-if="vm.isStatusSubmitFail" ng-click="vm.completeExperimentAndSign()">
                    <a href="#" i-translate="RESUBMIT_FOR_SIGNATURE"></a></li>
                <li role="menuitem"
                    ng-if="vm.isStatusSubmitFail || vm.isStatusSubmitted || vm.isStatusSigning || vm.isStatusSigned">
                    <a href="{{vm.apiUrl}}signature/document/content?documentId={{vm.experiment.documentId}}"
                       target="_blank"
                    i-translate="VIEW_RECORD_SUBMITTED_FOR_SIGNATURE"></a>
                </li>
                <li role="menuitem" ng-if="vm.isStatusArchieved">
                    <a href="{{vm.apiUrl}}signature/document/content?documentId={{vm.experiment.documentId}}"
                       target="_blank"
                    i-translate="VIEW_RECORD_ARCHIEVED"></a>
                </li>
            </ul>
        </div>

        <button type="submit" form="experimentForm"
                ng-disabled="!vm.isComponentsEditAllowed || experimentForm.$invalid || !vm.isEntityChanged"
                class="btn btn-primary">
            <span class="icon icon-save"></span><span class="m-l5" i-translate="SAVE"></span>
        </button>
        <button class="btn btn-default" ng-click="vm.refresh()" ng-disabled="!vm.isComponentsEditAllowed || !vm.isEntityChanged">
            <span class="icon icon-refresh"></span><span class="m-l5" i-translate="RESET"></span>
        </button>
        <button class="btn btn-default" ng-click="window.history.back()">
            <span class="icon icon-undo"></span><span class="m-l5" i-translate="BACK"></span>
        </button>
    </div>
</div>
